#!/bin/bash

if test ${#} -lt 1 ; then
	echo "error: Wrong usage! You need at least one argument."
	echo "       > expected argument is file name"
	echo "${0} FILENAME "
	exit 1
fi

filename=${1}
#export separatorB=${2-" "}
#echo "separatorB == '${separatorB}'" >&2

awk \
'{
	separator = " "
	c = 0;
	split($0 , arr, separator);
	for (v in arr)
		c++;
	for (m = c; m >= 1; m--)
		for (n = 1; n < m; n++)
			if (arr[m] == arr[n])
				delete arr[m];
	str = "";
	for (k = 1; k <= c; k++)
	{
		if (k == 1 )
		{
			str = arr[k]separator
		}
		else if (arr[k] != "")
			str = str""arr[k]separator
	}
	print substr(str, 1, length(str) - 1)
}' ${filename} 

exit 0
